//
//  AQQueue.m
//  AudioQueueDemo
//
//  Created by marco on 16/3/8.
//  Copyright © 2016年 Marco. All rights reserved.
//

#import "AQQueue.h"

@interface AQQueue ()

@property (nonatomic,strong) NSMutableArray* data;



@end

@implementation AQQueue
- (id)init
{
    if( self=[super init] )
    {
        _data = [[NSMutableArray alloc] init];
        _count = 0;
    }
    return self;
}


- (void)enqueue:(id)anObject
{
    [_data addObject:anObject];
    _count = _data.count;
}
- (id)dequeue
{
    //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    id obj = nil;
    if(_data.count > 0)
    {
        obj = [_data objectAtIndex:0];
        [_data removeObjectAtIndex:0];
        _count = _data.count;
    }
    //[pool release];
    return obj;
}

- (void)clear
{
    [_data removeAllObjects];
    _count = 0;
}

@end
